import Vue from 'vue';
import App from './App.vue';
import router from './router';
import store from './store';
import '@/assets/style/base.sass';
import ElementUI from 'element-ui';
import 'element-ui/lib/theme-chalk/index.css';
import axios from 'axios'

Vue.use(ElementUI);
Vue.prototype.axios = axios
// 接口地址的公共前缀
axios.defaults.baseURL = '/equipment'
// 请求过期事件 超过30秒没返回就直接放弃
axios.defaults.timeout = 30000
// 配置响应拦截器，请求时，在.then之前执行
axios.interceptors.response.use(({data})=>{
  // console.log('拦截器',response);
  if(data.code){
    Vue.prototype.$message.error(data.msg);
  }
  if(data.code === 9){
    // location.href = './#/login';
    router.push('/login')
  }
  return data
},error=>{
  return Promise.reject(error)
})
Vue.config.productionTip = false

//this.$router、this.$store
new Vue({
  router,
  store,
  render: h => h(App)
}).$mount('#app')
